if (!sessionStorage.getItem('token')) {
    window.location.href = "./login.html";
}

window.userInfo = function () {
    getUserInForAPI({}, function (res) {
        var { nickname, user_pic } = res.data.data;
        if (nickname == null) { //如果是新用户没有昵称，显示用户名
            $('.username').html(username)
        } else {
            $('.username').html(nickname);

        }
        if (user_pic == null) {
            var firstStr = username[0].toUpperCase();
            $('.avatar').html(firstStr).css('display', 'inline-block');
        } else {
            $('.layui-nav-img').show().attr('src', user_pic);
            $('.avatar').hide()
        }



    })
}
userInfo()

$('#logout').on('click', function () {
    sessionStorage.removeItem('token');
    window.location.href = "./login.html";

})